#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>

using namespace std;

static int square_root_period(const int n) {
    const int square_root = sqrt(n);
    int ans = 0;
    int a = 1;
    int b = 0;
    int c = 1;
    while (true) {
        int r = (a * square_root + b) / c;
        if (r == 2 * square_root)
            return ans;

        b -= c * r;
        int m = gcd(gcd(a, c), gcd(b, c));
        a /= m;
        b /= m;
        c /= m;

        int x = a * c;
        int y = -b * c;
        int z = a * a * n - b * b;
        a = x;
        b = y;
        c = z;
        
        ++ans;
    }
    return 0;
}

int main() {
    int ans = 0;
    for (int i = 1; i < 10000; ++i) {
        int root = sqrt(i) + 0.5;
        if (root * root != i && square_root_period(i) % 2)
            ++ans;
    }
    printf("%d\n", ans);    // 1322
}